package com.kelvem.saas.workbanch.fsm.aspect;

import com.kelvem.saas.workbanch.fsm.anno.handle.RegisterHandle;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;

import java.lang.reflect.Method;

/**
 * 标识使用的Entity
 * 但是目前没有实际作用
 */
@Aspect
@Component
@Slf4j
public class HandleAspect {
    
    /**
     * 定义一个切入点
     */
    @Pointcut("@annotation(com.kelvem.saas.workbanch.fsm.anno.handle.RegisterHandle)")
    public void annotationPointCut(){
        // do nothing
    }
    
    @Before("annotationPointCut()")
    public void doBefore(JoinPoint joinPoint) {
    
        // Todo 抽方法
        MethodSignature methodSignature = (MethodSignature)joinPoint.getSignature();
        Method method = methodSignature.getMethod();
        RegisterHandle annotation = method.getAnnotation(RegisterHandle.class);
        
        // todo HandleAspect
        
    }
    
    @After("annotationPointCut()")
    public void doAfter(JoinPoint joinPoint) {
    
    }
}
